import { Component, EventEmitter, HostListener, OnInit, Output } from '@angular/core';

@Component({
  selector: 'app-quick-task',
  templateUrl: './quick-task.component.html',
  styleUrls: ['./quick-task.component.scss'],
})
export class QuickTaskComponent implements OnInit {

  @Output() quickTask = new EventEmitter<string>();

  desc: string;
  constructor() {}

  ngOnInit(): void {}

  // onSubmit({ value, valid }, ev: Event): void {
  //   ev.preventDefault();

  //   console.log(value, valid);
  // }

  @HostListener('keyup.enter')
  sendQuickTask(): void {
    if (!this.desc || this.desc.length === 0 || !this.desc.trim()) {
      return;
    }

    this.quickTask.emit(this.desc);

    this.desc = '';
  }
}
